Xbasic

Helper::HtmlProcessor.ExtractTagAttributes Method

Syntax

c ExtractTagAttributes(C tagNames, C html, C format [, N limit = -1])

Arguments

tagNames

Comma separated list of tags to extract

html

Html source to scan for tags

format

Attributes to output for with separators.

limit

Optional limit (i.e. 1 means only process the first, 2 means process first 2, etc).

Description

Return list of attributes (in format) from only tags in comma separated tagname list.

In the following example, ExtractTagAttributes() is called to return the href, rel and type attributes in a cr-lf delimited list with '|||' separators between the attributes.

dim html as c = ""+http_get("www.cnn.com").body
? helper::HtmlProcessor::ExtractTagAttributes("link",html,"href|||rel|||type")
= http://www.cnn.com/|||canonical|||
http://www.cnn.com/favicon.ie9.ico|||Shortcut Icon|||image/x-icon
/tools/search/cnncom.xml|||search|||application/opensearchdescription+xml
/tools/search/cnncomvideo.xml|||search|||application/opensearchdescription+xml
http://i.cdn.turner.com/cnn/.e/img/3.0/global/misc/apple-touch-icon.png|||apple-touch-icon|||image/png
http://rss.cnn.com/rss/cnn_topstories.rss|||alternate|||application/rss+xml
http://rss.cnn.com/rss/cnn_latest.rss|||alternate|||application/rss+xml
http://edition.cnn.com|||alternate|||text/html
http://arabic.cnn.com|||alternate|||text/html
http://mexico.cnn.com|||alternate|||text/html
https://plus.google.com/u/0/b/117515799321987910349/117515799321987910349/posts|||publisher|||
http://z.cdn.turner.com/cnn/tmpl_asset/static/www_homepage/2624/css/hplib-min.css|||stylesheet|||text/css

See Also